home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Virtual User / Virtual User Current Release / Examples / External Tool Templates / CPlus Tool Template / Application.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-04  |  4.2 KB  |  109 lines  |  [TEXT/MPS ]

  1. /*
  2.  *    File:        Application.h
  3.  *
  4.  *    Contains:    xxx put contents here xxx
  5.  *
  6.  *    Written by:    Rick Violet
  7.  *
  8.  *    Copyright:    © 1992 by Apple Computer, Inc., all rights reserved.
  9.  *
  10.  *    Change History (most recent first):
  11.  *
  12.  *                11/18/92    RV        xxx put comment here xxx
  13.  *
  14.  *    To Do:
  15.  */
  16.  
  17. #ifndef __Application__
  18. #define __Application__
  19.  
  20. #include <Types.h>
  21. #include <Events.h>
  22. #include <Desk.h>
  23. #include <OSUtils.h>
  24. #include <String.h>
  25. #include <AppleEvents.h>
  26.  
  27. #include "Application.R.h"
  28.  
  29. #ifndef __Object__
  30. #include     "Object.h"
  31. #endif
  32.  
  33. #ifndef __THREADS__
  34. #include     "Threads.h"
  35. #endif
  36.  
  37. pascal    OSErr    AEOpenHandler (AppleEvent*, AppleEvent*, long );
  38. pascal    OSErr    AEOpenDocHandler (AppleEvent*, AppleEvent*, long );
  39. pascal    OSErr      AEPrintHandler (AppleEvent*, AppleEvent*, long );
  40. pascal    OSErr    AEQuitHandler (AppleEvent*, AppleEvent*, long );
  41.  
  42.  
  43. //—————————————————————————————————————————————————————————————————————————————————————
  44. //    Application class    -    Implements a basic System Seven application
  45. //                            with handlers for the minimum 4 Apple Events 
  46. //                            plus the VU external tool service Apple event. 
  47. //—————————————————————————————————————————————————————————————————————————————————————
  48. class Application : public Object
  49. {
  50. private:    Boolean            fIsThreaded;        // Thread Manager or Package is present
  51. private:    Boolean            fDone;                // set to true when we are ready to quit
  52. private:    EventRecord        fTheEvent;            // our event record
  53. private:    WindowPtr        fWhichWindow;        // currently active window
  54. private:    Boolean            fInBackground;        // true if our app is suspended
  55. private:    Boolean            fWantFrontClicks;    // true if we want front clicks
  56. private:    long            fCursorTicks;        // used to spin the cursor
  57. private:    ProcessInfoRec    fProcessInfo;        // Process info for this application
  58. private:    long            fSleepTicks;        // Sleep ticks for WaitNextEvent
  59. public:        Str31            fProcessName;        // Name of this application
  60.  
  61.         /*SBR Hacked this in 12/03/94 to fix an alleged AE Manager bug */
  62. public:        AppleEvent*        fMessagePtrOrig;    //————    the original from AE Manager before copying
  63. public:        AppleEvent*        fReplyPtrOrig;        //————    the original from AE Manager before copying
  64.  
  65.         /*SBR Hacked this in 10/16/94 */
  66.     //————    Create RequestDispatcher; use a separate thread if application is threaded
  67. private:            void            CreateRequestDispatcher();
  68. public:                long            SetSleepTicks( long pSleepTicks );
  69. public:                Boolean            IsThreaded(){ return fIsThreaded; };
  70.  
  71. public:                                Application(void);                    //————    Constructor
  72. public:        virtual                    ~Application(void);                //————    Destructor
  73. public:                void            Run();                                //————    the main event loop
  74. public:                Boolean            DoEvent( unsigned long pSleepTicks = 0, short pEventMask = everyEvent );    //————    handle one event
  75. public:                void            DoMenuCommand(    short menuID, short menuItem );    //———— Do a menu Request
  76. public:                void            SpinTheCursor();
  77.  
  78.         //————    Loop control methods you may need to override
  79. protected:    virtual    OSErr            InstallRequiredAEHandlers(void);
  80. protected:    virtual void            ExitLoop(void);                // to exit application, call this routine
  81.     
  82.         //————    event handlers methods you may want to override
  83. protected:    virtual void            DoMouseDown(void);            // Calls DoContent, DoGrow, DoZoom, etc
  84. protected:    virtual void            DoKeyDown(void);            // also called for autokey events
  85. protected:    virtual void            DoOSEvent(void);            // Calls DoSuspend, DoResume and DoIdle as apropos
  86. protected:    virtual void            DoHighLevelEvent(void);        // calls AEProcessAppleEvents
  87.     
  88. protected:            void            DoMouseInSysWindow(void) { SystemClick(&fTheEvent, fWhichWindow); }
  89.             
  90. protected:    virtual    unsigned long    SleepVal(void);                                    //———— how long to sleep in WaitNextEvent
  91. protected:            void            InitializeToolBox(void);                        //————    Init ToolBox
  92. protected:            void            GetThisProcessInfo(void);                        //————    get Process info for this app
  93. protected:            Boolean            TrapAvailable(short tNumber,TrapType tType);    //————    Is trap implemented???
  94. protected:            void            Terminate(void);
  95.  
  96. /*SBR Hacked this in 12/03/94 to fix an alleged AE Manager bug */
  97. void            FixAEManagerBugPart2();
  98.  
  99. };
  100.  
  101.     //————    call TerminalError to display error message, then ExitShell...
  102. void    TerminalError(short errResID, short errCode);    
  103.  
  104.         /*SBR Hacked this in 10/16/94 */
  105.     //————    Entry point for RequestDispatcher thread
  106. void*    RequestDispatcherThread(void *threadParam);    
  107.  
  108. #endif
  109.